/* Copyright (C) 2007 Notyet

这是algebra库的demo。

algebra是一个基于C开发的库，旨在解决代数式化简与解简单方程的问题。

联系方式：
E-Mail:nt1900@gmail.com  */

#include <stdio.h>
#include "libalgebra.h"
#include "alglib.h"

FORMULA*	alg_create_formula(char attr);
int		alg_destroy_formula(FORMULA* fml);

void say_hello()
{
	printf("\n\nThis is a Demo of LibAlgebra\n%s\n",alg_about());
	printf("SHOW_DETAIL:%d\n",alg_check_show_detail());
	printf("\nPlease press Enter to continue.....");
	//getchar();
}

int main()
{
	alg_init();		//使用libalgebra之前，必须先调用初始化函数
	say_hello();
	printf("\nDebug Infomation:\n");
	FORMULA* fml;
	fml=alg_create_formula(0);
	fml->data.terms.head=alg_create_term(alg_create_formula(2));
	(fml->data.terms.head)->next=alg_create_term(NULL);
	((fml->data.terms.head)->term)->coefficient=alg_create_formula(1);
	printf("ok1\n");
		switch(alg_check_formula_attr(fml->attr))
	{
		case FORMULA_ATTR_TERMS:		printf("::TERMS\n");
							break;
		case FORMULA_ATTR_FRACTION:	printf("::FRACTION\n");
							break;
		case FORMULA_ATTR_RADICAL:	printf("::RADICAL\n");
							break;
		case FORMULA_ATTR_LETTER:	printf("::LETTER\n");
							break;
		case FORMULA_ATTR_FUNCTION:	printf("::FUNCTION\n");
							break;
	}
	printf("ok2\n");
	printf("Test for the function \"gcd\":\tgcd(3*15*17,4*15*3)=%d\n",gcd(3*15*17,4*15*3));
	if(alg_destroy_formula(fml))printf("\nok3\n");
	printf("Checking if alg_letter_table is empty:\n");
	int i;
	for(i=0;i<11;i++)printf("No.%d content:%s\n",i,alg_letter_table[i].name);
	printf("\nok4\n");
	return 0;
}
